# -*- coding: utf8 -*-

import os
import sys
reload(sys) 
sys.setdefaultencoding('utf8')
import caller
import webkit
import webpage
import webelement
import time

gconfig = caller.GlobalConfig()
gconfig.init("10.58.222.103:2181")

wk = webkit.WebKit("test")
page = wk.getWebPage("http://www.woqu.com/australia-ticket-detail-via_bf_ceicsohg", 30000, 40000)

if page.waitForCssSelector("#package", 100):
    pe = page.getElementByCssSelector("#total-price")
    print pe.getText()
    e = page.getElementByCssSelector("#package")
    e.sendKeys("keypress", caller.Keys.Key_Down)
    e.sendKeys("keypress", caller.Keys.Key_Enter)
    #e.selectOptionByIndex(1)
    
    print pe.getText()

    buf = page.webPageImageBuffer()
    fp = open("page.png", "w")
    fp.write(buf)
    fp.close()

page.destroy()
wk.release()
